package com.xiaozhen.blog.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @create 2023-05-23 9:42
 */
@Configuration
public class RabbitMQConfig {

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("exchange");
    }

    @Bean
    public Queue likeQueue() {
        return new Queue("like.queue");
    }

    @Bean
    public Queue commentQueue() {
        return new Queue("comment.queue");
    }

    @Bean
    public Queue followQueue() {
        return new Queue("follow.queue");
    }

    @Bean
    public Binding likeBinding() {
        return BindingBuilder.bind(likeQueue()).to(directExchange()).with("like");
    }

    @Bean
    public Binding commentBinding() {
        return BindingBuilder.bind(commentQueue()).to(directExchange()).with("comment");
    }

    @Bean
    public Binding followBinding() {
        return BindingBuilder.bind(followQueue()).to(directExchange()).with("follow");
    }
}
